package vista;


import java.awt.BorderLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javabean.JPanelImagen;
import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;

import modelo.dao.UsuarioDao;
import modelo.dto.Usuario;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class vListadoPuntuacion extends javax.swing.JFrame {
	private JScrollPane jscListadoPuntuacion;
	private JPanelImagen jpanfondo;
	private JTable puntuacion;
	private JComboBox cmbdificultad;
	private JButton btnConsultar;
	private JButton btnSalir;
	private vTablaPuntuacion modelo;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public vListadoPuntuacion() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			BorderLayout thisLayout = new BorderLayout();
			getContentPane().setLayout(thisLayout);
			{
				jpanfondo = new JPanelImagen();
				getContentPane().add(jpanfondo, BorderLayout.CENTER);
				jpanfondo.setRutaImagen("/imagenes/niveles.jpg");
				{
					jscListadoPuntuacion = new JScrollPane();
					jpanfondo.add(jscListadoPuntuacion);
					jscListadoPuntuacion.setBounds(136, 72, 329, 253);
					jscListadoPuntuacion.setBackground(new java.awt.Color(255,255,255));
					jscListadoPuntuacion.setForeground(new java.awt.Color(192,192,192));
					{
						puntuacion = new JTable();
						jscListadoPuntuacion.setViewportView(puntuacion);
						modelo = new vTablaPuntuacion();
						puntuacion.setModel(modelo);
					}
				}
				{
					btnSalir = new JButton();
					jpanfondo.add(btnSalir);
					btnSalir.setText("Salir");
					btnSalir.setBounds(246, 345, 94, 32);
					btnSalir.setFont(new java.awt.Font("Segoe UI",1,12));
					btnSalir.setForeground(new java.awt.Color(128,64,0));
				}
				{
					btnConsultar = new JButton();
					jpanfondo.add(btnConsultar);
					btnConsultar.setText("Consultar");
					btnConsultar.setBounds(196, 23, 108, 33);
					btnConsultar.setForeground(new java.awt.Color(128,64,0));
					btnConsultar.setFont(new java.awt.Font("Segoe UI",1,12));
				}
				{
					ComboBoxModel cmbdificultadModel = 
						new DefaultComboBoxModel(
								new String[] { "Basico", "Intermedio", "Dificil" });
					cmbdificultad = new JComboBox();
					jpanfondo.add(cmbdificultad);
					cmbdificultad.setModel(cmbdificultadModel);
					cmbdificultad.setBounds(29, 23, 148, 32);
				}

				//jpanfondo.setLayout(jpanfondoLayout);
			}
			pack();
			this.setSize(608, 454);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	public void cargarDatosPuntuacion(){
		UsuarioDao usuariodao = new UsuarioDao();
		List<Usuario> usuarios = usuariodao.consultarPuntuacion();
		puntuacion.setModel(new vTablaPuntuacion(usuarios));

	}
	public void agregarListener(ActionListener accion)
	{
		btnSalir.addActionListener(accion);
		btnConsultar.addActionListener(accion);
		cmbdificultad.addActionListener(accion);
	}
	public void setResultados(AbstractTableModel abstractTableModel) {
		puntuacion.setModel(abstractTableModel);
	}

	public String getDificultad(){
		return cmbdificultad.getSelectedItem().toString();
	}
	public void Mensaje(String texto){
		JOptionPane.showMessageDialog(this, texto);
	}
}
